<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>首页</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <script type="text/javascript" src="libs/handlebars.min.js" ></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
  <div class="container">
  	 <div class="page-header">
        <h2 class="text-center"><strong>账单</strong></h2>
      </div>
  </div>
 
  <div class="container">
  	<div class="row">
  		<div class="col-md-8">
  			<ul class="nav nav-pills" >
  				<li class="active">
  					<a href="#"  >首页</a>
  				</li>
  				<li >
  					<a href="yonghu.html" >用户:<span id="yh"></span></a>
  				</li>
  				<li >
  					<a href="outadd.html">新加支出</a>
  				</li>
  				<li >
  					<a href="inadd.html">新加收入</a>
  				</li>
  				<li >
  					<a href="sta.html">统计</a>
  				</li> 
				<li >
  					<a href="search.html">查询</a>
  				</li>
  			</ul>
  		</div>
  		<div class="col-md-1 col-md-offset-3">
	  		<ul class="nav nav-pills">
	  			<li >
  					<button id="quit" class="btn  btn-block">退出</button>
  				</li>
	  		</ul>
  		</div>
  	</div>
  </div>
  
  <div class="container">
  	<div class="row">
  		<div class="col-md-12">
  			<hr>
  		</div>
  	</div>
  </div>

	<div class="container">
	  	<div class="row">
	  		<div class="col-md-6">
		  		 <div class="panel panel-primary">
		  		 	<div class="panel-heading">一周内收入</div>
		  			<div class="panel-body" id="text1"></div>
		  		</div>
		  	</div>	
			<div class="col-md-6">
			  	<div class="panel panel-primary">
			  		<div class="panel-heading">一周内支出</div>
			  		<div class="panel-body" id="text2"></div>
			  	</div>
			</div> 
		</div>
	</div>
	
	<div class="container">			 		
	  	<div class="row">
	  		<div class="col-md-12">
	  			<div class="panel panel-primary">
	  				<div class="panel-heading">最近四笔收入</div>
			  		<div class="panel-body" id="list1"></div>
	  			</div>
	  		</div>
	  	</div>		
	  	<div class="row">
	  		<div class="col-md-12">
	  			<div class="panel panel-primary">
	  				<div class="panel-heading">最近四笔支出</div>
			  		<div class="panel-body" id="list2"></div>
	  			</div>
	  		</div>
	  	</div>	
	</div>
	 

<script id="template" type="text/x-handlebars-template">
	{{#each item}}
		<div class="panel panel-default col-md-3">
			<div class="panel-body">
				<dl>
					<dt>时间</dt><dd>{{date_time}}</dd>
					<dt>地点</dt><dd>{{place}}</dd>
					<dt>金额</dt><dd>{{mm}}</dd>
					<dt>类别</dt><dd>{{kind}}</dd>
				</dl>
			</div>	
		</div>	
	{{/each}}
</script>
<!--  <script id="template1" type="text/x-handlebars-template">
	{{#each item1}}
		<div class="panel panel-default col-md-3">
			<div class="panel-body">
				<dl>
					<dt>时间</dt><dd>{{date_time}}</dd>
					<dt>地点</dt><dd>{{place}}</dd>
					<dt>金额</dt><dd>{{mm}}</dd>
					<dt>类别</dt><dd>{{kind}}</dd>
				</dl>
			</div>	
		</div>	
	{{/each}}
</script>-->
<script>
	$(function(){
		$.getJSON('money.action',function(res){
			console.log(res);
			$('#text1').text(res.mi);
		})
		$.getJSON('money.action',function(res){
			console.log(res);
			$('#text2').text(res.mo);
		})
		$.getJSON('users.action',function(res){
			console.log('nickname: ' + res);
			$('#yh').text(res.nickname);
		})
 		$.getJSON('jinqi.action',function(res){
			console.log(res);
			var data={'item':res};
			var t=Handlebars.compile($('#template').html());
			$('#list1').html(t(data));
		}) 
		$.getJSON('jinqi1.action',function(res){
			console.log(res);
			var data={'item':res};
			var t=Handlebars.compile($('#template').html());
			$('#list2').html(t(data));
		}) 
		$('#quit').click(function(){
			$.post('quit.action',{},
			function(res){
				if("q"==res){
					window.location.href='login.html';
				}
			})
		})
	})
</script>
</body>

</html>